<template>
  <div class="col">
    <div class="row-center">
      <Menu mode="horizontal" active-name="1" @on-select="onSelected" v-model="showMenu">
        <MenuItem name="1">
          公告与问答搜索
        </MenuItem>
        <MenuItem name="4">

          新消息管理页面
        </MenuItem>
        <MenuItem name="3">

          新闻列表页面
        </MenuItem>
        <MenuItem name="2">

          新题材管理页面
        </MenuItem>

        <MenuItem name="5">

          板块关键词管理页面
        </MenuItem>
        <MenuItem name="6">

          题材采集页面

        </MenuItem>
      </Menu>
    </div>
    <div>
      <Announcement  v-show="showMenu===1" ref="announcement"></Announcement>
      <SubjectUncheck @toAddKeyword="toAddKeyword" @toEditStock="toEditStock" v-show="showMenu===2"
                      ref="subjectUncheck"></SubjectUncheck>
      <NewsList v-show="showMenu===3" ref="newsList"></NewsList>
      <NewsUncheck v-show="showMenu===4" ref="newsUncheck"></NewsUncheck>
      <BlockKeyword v-show="showMenu===5" ref="blockKeyword"></BlockKeyword>
      <SubjectCollect v-show="showMenu===6" ref="subjectCollect"></SubjectCollect>
    </div>

  </div>
</template>

<script>

  import SubjectUncheck from '../components/SubjectUncheck.vue'
  import NewsUncheck from '../components/NewsUncheck.vue'
  import NewsList from '../components/NewsList.vue'
  import SubjectCollect from '../components/SubjectCollect.vue'
  import BlockKeyword from '../components/BlockKeyword.vue'
  import Announcement from '../components/Announcement.vue'


  export default {
    name: 'Main',
    components: {
      SubjectUncheck,
      NewsUncheck,
      NewsList,
      SubjectCollect,
      BlockKeyword,
      Announcement
    },
    data() {
      return {
        showMenu: 1
      }
    },

    methods: {
      toEditStock(item) {
        this.showMenu = 6;
        this.$refs.subjectCollect.input = item.topicName;
        this.$refs.subjectCollect.doSearchFromMain();

      },
      toAddKeyword(item) {
        this.showMenu = 5;
        this.$refs.blockKeyword.input = item.blockName;
        this.$refs.blockKeyword.doSearchByTopicName(item);
      },
      onSelected(name) {
        this.showMenu = Number(name);
        switch (this.showMenu) {
          case 1:
            this.$refs.subjectCollect.methods.initSubjectTable();
            break;
          case 2:
            this.$refs.subjectUncheck.methods.initTopicNameList();
            break;
          case 3:
            this.$refs.newsList.methods.initBlockNameData();
            this.$refs.newsList.methods.initTopicNameList();
            break;
          case 4:
            this.$refs.newsUncheck.methods.initBlockNameData();
            break;
          default:

        }
      }
    }
  }
</script>

<style scoped>
  .btn {
    margin: 20px;
  }

  @media screen and (min-width: 1281px) and (max-width: 2000px) {

  }


</style>
